<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改收支记录')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-transaction-edit" th:object="${finTransaction}">
            <input name="transactionId" th:field="*{transactionId}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">用户信息：</label>
                    <div class="col-sm-8">
                        <input name="userId" th:field="*{userId}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-3 control-label is-required">账户名称：</label>
                        <div class="col-sm-8">
                            <select id="accountId" name="accountId" class="form-control" required>
                                <option value="">--请选择账户名称--</option>
                                <option th:each="account : ${accounts}"
                                        th:value="${account.accountId}"
                                        th:text="${account.accountId+'('+account.accountName+')'}">
                                </option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">收支类别：</label>
                    <div class="col-sm-8">
                        <select id="categoryId" name="categoryId" class="form-control" required>
                            <option value="">--请选择账户ID--</option>
                            <option th:each="category : ${categories}"
                                    th:value="${category.categoryId}"
                                    th:text="${category.categoryId+'('+ categoryName + ')'}">
                            </option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">金额：</label>
                    <div class="col-sm-8">
                        <input name="amount" th:field="*{amount}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">交易类型：</label>
                    <div class="col-sm-8">
                        <select name="transactionType" class="form-control" th:with="type=${@dict.getType('fin_transaction_type')}" required>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{transactionType}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">交易日期：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="transactionDate" th:value="${#dates.format(finTransaction.transactionDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注：</label>
                    <div class="col-sm-8">
                        <input name="remark" th:field="*{remark}" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "pims/transaction";
        $("#form-transaction-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-transaction-edit').serialize());
            }
        }

        $("input[name='transactionDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>